package com.fantastic.web.controller.app;

import com.fantastic.common.exception.enums.RespStatusInfo;
import com.fantastic.common.result.ResultData;
import com.fantastic.model.pojo.zjs.AccountMember;
import com.fantastic.service.zjs.AccountMemberService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: rxx
 * @since: 2024/6/4 20:38
 * @description: 账号和会员卡关联信息请求控制器
 */
@RestController
@RequestMapping("/app")
public class AccountMemberController {
    @Resource
    private AccountMemberService accountMemberService;

    /**
     * 查询单个账号下的所有会员卡关联信息
     *
     * @param accountMember
     * @return
     */
    @GetMapping("/listAccountMemberApp")
    public ResultData listAccountMemberApp(AccountMember accountMember) {
        return new ResultData(RespStatusInfo.OK, accountMemberService.listAccountMember(accountMember));
    }

    /**
     * 查询单个的账号和会员卡关联信息
     *
     * @param accountId
     * @param memberId
     * @return
     */
    @GetMapping("/getAccountMemberApp")
    public ResultData getAccountMemberApp(Integer accountId, Integer memberId) {
        return new ResultData(RespStatusInfo.OK, accountMemberService.getAccountMember(accountId, memberId));
    }

    /**
     * 添加账号和会员卡关联信息
     *
     * @param accountMember
     * @return
     */
    @PostMapping("/insertAccountMemberApp")
    public ResultData insertAccountMemberApp(AccountMember accountMember) {
        return new ResultData(RespStatusInfo.OK, accountMemberService.insertAccountMember(accountMember));
    }

    /**
     * 修改账号和会员卡关联信息
     *
     * @param accountMember
     * @return
     */
    @PostMapping("/updateAccountMemberApp")
    public ResultData updateAccountMemberApp(AccountMember accountMember) {
        return new ResultData(RespStatusInfo.OK, accountMemberService.updateAccountMember(accountMember));
    }


    /**
     * 删除账号和会员卡关联信息
     *
     * @param accountId
     * @param memberId
     * @return
     */
    @PostMapping("/deleteAccountMemberApp")
    public ResultData deleteAccountMemberApp(Integer accountId, Integer memberId) {
        return new ResultData(RespStatusInfo.OK, accountMemberService.deleteAccountMember(accountId, memberId));
    }

}
